package com.guys8.cemsbackend.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guys8.cemsbackend.DTO.HealthInformation;
import com.guys8.cemsbackend.entity.ClassUser;
import com.guys8.cemsbackend.entity.Nacid;
import com.guys8.cemsbackend.mapper.HealthMapper;
import com.guys8.cemsbackend.entity.Health;
import com.guys8.cemsbackend.service.HealthService;
import com.guys8.cemsbackend.utils.Others.ListUtil;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * (Health)表服务实现类
 *
 * @author breeze
 * @since 2022-08-24 16:53:22
 */
@Service("healthService")
public class HealthServiceImpl extends ServiceImpl<HealthMapper, Health> implements HealthService {

    public Health getusernowHealth(Integer userid, Date ndate){
        Map<String,Object> accountMap = new HashMap<>();
        accountMap.put("user_id",userid);
//        accountMap.put("up_time",ndate);
        List<Health> healths = listByMap(accountMap);
        if(healths.size()==0) return null;
        return healths.get(healths.size()-1);
    }

    public List<Health> getallById(Integer userId) {
        Map<String,Object> accountMap = new HashMap<>();
        accountMap.put("user_id",userId);
        List<Health> healths = listByMap(accountMap);
        return ListUtil.getOppoList(healths);
    }
}

